#!/bin/bash
# Detect Caps Lock status, and send a notify on windows screen

while true
do
	sleep 0.5
	CAPS_STATE=$(xset q)
	CAPS_ON='on'
	PATTERN='Caps Lock:\s+(on|off)'

	if [[ "$CAPS_STATE" =~ $PATTERN ]]; then
	  # Match
	  if [[ "${BASH_REMATCH[1]}" == "$CAPS_ON" ]]; then
	  	notify-send "Caps Lock is ON!!!" -t 300
	  fi
	fi
done
